package com.flying.drools;

import com.flying.drools.model.Customer;
import com.flying.drools.model.Item;
import com.flying.drools.model.Order;
import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;

public class App {
    public static final void main(String[] args) {
        System.out.println("Bootstrapping the Rule Engine...");
        KieServices ks = KieServices.get();
        KieContainer kieContainer = ks.getKieClasspathContainer();
        KieSession kieSession = kieContainer.newKieSession("basicKS");


        Item item = new Item("A", 123.0, 234.0);
        kieSession.insert(item);
        Customer customer = new Customer();
        customer.setName("walker");
        customer.setCategory(Customer.Category.SILVER);
        Order order = new Order();
        order.setCustomer(customer);
        kieSession.insert(order);
        kieSession.insert(customer);



        int fired = kieSession.fireAllRules();
        System.out.println("Number of Rules executed = " + fired);
        kieSession.dispose();
    }
}